FROM wuhongbo7/base:jdk8-python3

LABEL maintainer="rainb <rainbow-w@qq.com>"

# 环境设置
ENV HADOOP_VERSION=3.1.3
ENV HADOOP_HOME=/opt/hadoop-${HADOOP_VERSION}
ENV PATH=${PATH}:${HADOOP_HOME}/bin
ENV HADOOP_CONF_DIR=${HADOOP_HOME}/etc/hadoop
ENV HADOOP_URL=https://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/hadoop-${HADOOP_VERSION}/hadoop-${HADOOP_VERSION}.tar.gz

# 脚本拷贝
COPY setConf.py /tmp/setConf.py
COPY conf.properties /tmp/conf.properties
# ADD hadoop-3.1.3.tar.gz /opt/

# 安装hadoop
RUN wget -S "${HADOOP_URL}" -O /tmp/hadoop.tar.gz \
    && tar -xvf /tmp/hadoop.tar.gz -C /opt/ \
    && rm /tmp/hadoop.tar.gz* \
    mkdir /opt/hadoop-3.1.3/logs \
    && python3 /tmp/setConf.py core-site \
    && python3 /tmp/setConf.py hdfs-site \
    && python3 /tmp/setConf.py yarn-site \
    && python3 /tmp/setConf.py mapred-site \
    && mkdir -p /home/hadoop/dfs/name \
    && mkdir -p /home/hadoop/dfs/data \
    && mkdir -p /home/hadoop/dfs/tmp \
    && touch /home/hadoop/dfs/dfs.hosts.exclude \
    && touch /home/hadoop/dfs/dfs.hosts \
    && rm -rf ${HADOOP_HOME}/bin/*.cmd ${HADOOP_HOME}/sbin/*.cmd ${HADOOP_HOME}/sbin/*all* ${HADOOP_CONF_DIR}/*.cmd \
    && hdfs namenode -format

# HDFS 9000 9870 9871 9864 YARN 8088 8042 19888 HBASE 60010 16010 SPARK 7077 18080
EXPOSE 9000 9870 9871 9864 8088 8042 19888 60010 16010 